package cn.study.spaceconPart;

import static java.lang.System.currentTimeMillis;

/**
 * @Author     ：跟大佳一起学
 * @Description：空间局部性原则
 */
public class SpacePartTest {

    public static void main(String[] args) {
        int[][] array = new int[64 * 1024][1024];
        // 方法1、横向遍历
        long begin = currentTimeMillis();
        for(int i = 0; i < 64 * 1024; i ++)
            for(int j = 0; j < 1024; j ++)
                array[i][j] ++;
        System.out.println("横向遍历:"+(currentTimeMillis() - begin));
        begin = currentTimeMillis();
        // 方法2、纵向遍历
        for(int i = 0; i < 1024; i ++)
            for(int j = 0; j < 64 * 1024; j ++)
                array[j][i] ++;
        System.out.println("纵向遍历:"+(currentTimeMillis() - begin));
    }
}
